package com.sense.kukoo.biz_media.adapter

import android.view.View
import com.sense.kukoo.biz_media.adapter.provider.*
import com.sense.kukoo.common.repo.biz.CommentContentBean
import com.sense.kukoo.common.repo.http.bean.CommentRecordBean
import com.sense.kukoo.common.wiget.adapter.MultiItemAdapter

class CommentContentAdapter(
    data: ArrayList<CommentContentBean>,
    val listener:CommentListener,
): MultiItemAdapter<CommentContentBean>(data) {

    private val TAG: String = javaClass.simpleName
    private var creatorId: Long = -1
    private var currentUserId: Long = -1

    private val mCommentLevel1ItemProvider = CommentLevel1ItemProvider(listener)
    private val mCommentLevel2ItemProvider = CommentLevel2ItemProvider(listener)

    init {
        addItemProvider(mCommentLevel1ItemProvider)
        addItemProvider(mCommentLevel2ItemProvider)
        addItemProvider(CommentEnd2MoreItemProvider(listener))
        addItemProvider(CommentEnd2HideItemProvider(listener))
        addItemProvider(CommentEmptyItemProvider())
        addItemProvider(CommentEnd2SpaceProvider())
    }

    override fun getItemType(data: MutableList<CommentContentBean>, position: Int): Int {
        return data.get(position).type
    }

    fun setIds(creatorId: Long, currentUserId: Long){
        this.creatorId = creatorId
        this.currentUserId = currentUserId
        mCommentLevel1ItemProvider.setCreatorId(creatorId, currentUserId)
        mCommentLevel2ItemProvider.setCreatorId(creatorId, currentUserId)
    }

    interface CommentListener{
        fun onReplyComment(parent: CommentRecordBean?, data: CommentRecordBean)
        fun onBtnMoreClick(anchor: View, parent: CommentRecordBean?, data: CommentRecordBean)
        fun onViewMoreComment(data: CommentRecordBean)
        fun onHideComment(data: CommentRecordBean)
    }
}